﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using GraphLayout;
using TreeContainer;
using PresentationWpf.XMlWorker;

namespace PresentationWpf
{
    /// <summary>
    /// Interaction logic for TreeViewer.xaml
    /// </summary>
    public partial class TreeViewer : Window
    {
        Arbore.Arbore Ar;
        public TreeViewer(ref Arbore.Arbore Arb)
        {
            Ar = Arb;
            InitializeComponent();
            
        }

      

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
           
            var V = new Viewer();
            V.setArbore(Ar);
            grd.Children.Clear();
            V.VerticalAlignment = VerticalAlignment.Top;
            V.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            grd.Children.Add(V);
           
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            XMLExporter.export(ref Ar);
        }

        private void button2_Click(object sender, RoutedEventArgs e)
        {
            Arbore.Arbore arb = new Arbore.Arbore();
            XMLLoader.populateTreeview(ref arb);
            var V = new Viewer();
            V.setArbore(arb);
            grd.Children.Clear();
            V.VerticalAlignment = VerticalAlignment.Top;
            V.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            grd.Children.Add(V);
            Ar = arb;




          
         /*   Tree.Children.Clear();
            O.Content = "dsadsa";
            Tree.AddRoot(O);
            LoaderTree laoader = new LoaderTree(); 
            laoader.loadeTree(arb, ref O, ref  Tree);*/
        }

        private void button3_Click(object sender, RoutedEventArgs e)
        {
            SalvareInDB s = new SalvareInDB(ref Ar);
            s.ShowDialog();
        }

        private void button5_Click(object sender, RoutedEventArgs e)
        {
            Arbore.Arbore arb = new Arbore.Arbore();
            SelectorFromDB s = new SelectorFromDB(ref arb);
            s.ShowDialog();
            var V = new Viewer();
            V.setArbore(arb);
            grd.Children.Clear();
            V.VerticalAlignment = VerticalAlignment.Top;
            V.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            grd.Children.Add(V);
            Ar = arb;
        }
    }
}
